TableGetString Subroutine

private subroutine TableGetString(valueIn, tab, keyIn, keyOut, valueOut)

returns a string from column defined by keyOut corresponding to valueIn contained in column defined by keyIn. Arguments: valueIn input value tab table to search in keyIn defines header of the column of the input value keyOut defines header of the column of the output value

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: valueIn
type(Table), intent(in) :: tab
character(len=*), intent(in) :: keyIn
character(len=*), intent(in) :: keyOut
character(len=*), intent(out) :: valueOut

Variables

Type Visibility Attributes Name Initial
type(Column), public, POINTER :: colIn
type(Column), public, POINTER :: colOut
logical, public :: foundValue
integer(kind=short), public :: i
character(len=100), public :: string

Source Code

SUBROUTINE TableGetString &
!
( valueIn, tab, keyIn, keyOut, valueOut )

! Module used:
USE StringManipulation, ONLY: &
! imported routines:
StringCompact, StringToUpper, StringToFloat, ToString

USE LogLib, ONLY : &
! Imported Routines:
Catch


IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
REAL (KIND = float),  INTENT (IN) :: valueIn
CHARACTER (LEN = *),  INTENT (IN) :: keyIn
CHARACTER (LEN = *),  INTENT (IN) :: keyOut

! Type defined arguments with intent (in):
TYPE (Table), INTENT (IN) :: tab

! Scalar arguments with intent(in):
CHARACTER (LEN = *), INTENT (OUT) :: valueOut

! Local scalars:
TYPE (Column), POINTER :: colIn
TYPE (Column), POINTER :: colOut
INTEGER (KIND = short) :: i
CHARACTER (LEN = 100)  :: string
LOGICAL                :: foundValue
!------------end of declaration------------------------------------------------
!inizialization
foundValue = .FALSE.
!find columns to be processed
DO i = 1, tab % noCols
  string = StringCompact (StringToUpper (tab % col (i) % header) ) 
  IF ( string == StringToUpper(keyIn) ) THEN
    colIn => tab % col (i) !colIn is an alias of the input column
  ELSE IF ( string == StringToUpper(keyOut) ) THEN  
    colOut => tab % col (i) !colOut is an alias of the output column
  END IF 
END DO


DO i = 1, tab % noRows
  IF ( StringToFloat (colIn % row (i)) == valueIn ) THEN
    foundValue = .TRUE.
    valueOut = colout % row (i)
  END IF
END DO
IF ( .NOT. foundValue ) THEN
  CALL Catch ('error', 'TableLib',   &
       TRIM ( ToString (valueIn) ) // ' not found in table: ' ,  &
	    argument = tab % id )
END IF

RETURN  

END SUBROUTINE TableGetString